<template>
  <fade-animetion>
    <div class="container" @click="handelGallaryClick">
      <div class="wrapper">
        <swiper :options="swiperOption" >
        <swiper-slide v-for="(item,index) in imgs" :key="index">
          <img class="gallary-img"  :src='item' alt="">
        </swiper-slide>
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
      </div>
    </div>
  </fade-animetion>
</template>

<script>
import FadeAnimetion from "common/fade/FadeAnimation";
export default {
  name: "gallary",
  props: {
    imgs: {
      type: Array,
      default() {
        return [];
      }
    }
  },
  data() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination ",
        paginationType: "fraction", // 类型 1 2 3 4
        observeParents: true, // 父级元素
        observer: true //或是当前元素 发生变化 更新swiper
      }
    };
  },
  methods: {
    handelGallaryClick() {
      this.$emit("close");
    }
  },
  components: {
    FadeAnimetion
  }
};
</script>
<style lang="stylus" scoped>
.container >>> .swiper-container {
  overflow: inherit;
}

.container {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background: #000;
  z-index: 999;
  display: flex;
  flex-direction: column;
  justify-content: center;

  .wrapper {
    // background: #fff;
    width: 100%;
    height: 0;
    padding-bottom: 100%;

    // overflow: hidden;
    .gallary-img {
      width: 100%;
    }
  }

  .swiper-pagination {
    color: #fff;
    bottom: -1rem !important;
  }
}
</style>
